<?php

include_once 'common.php';

date_default_timezone_set("PRC");
$currentDate = date("Y-m-d");

$sql = "SELECT * FROM `trex_exercises` WHERE `startDate`<='{$currentDate}' AND `endDate`>='{$currentDate}' ORDER BY `updateTime` DESC";
$result = exec_sql($sql);
if ($result && gettype($result) == 'array' && count($result) > 0) {
  foreach ($result as $key => $value) {
    $result[$key]['subjects'] = json_decode($value['subjects']);
  }
  output($result);
} else {
  output([]);
}
